package com.web.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.PageInfo;
import com.web.entity.SysBooth;
import com.web.entity.SysPoster;
import com.web.entity.SysUser;
import com.web.service.SysBoothService;

@Controller
@RequestMapping("booth")
public class SysBoothController {

	@Autowired
	private SysBoothService sysBoothService;

	@RequestMapping("tap")
	public String tap() {
		return "manage/adminBooth";
	}

	@ResponseBody
	@RequestMapping("sysBooth")
	public List<SysBooth> sysBooth() {
		return sysBoothService.queryAllsysBooth();
	}

	@ResponseBody
	@RequestMapping("AllBooth")
	private PageInfo<SysBooth> list(SysBooth sb, Integer pageNum, Integer pageSize) {

		return sysBoothService.selectAllPoster(sb, pageNum, pageSize);
	}

	@ResponseBody
	@RequestMapping("updateState")
	public Map<String, Object> updateState(@RequestParam("id") Integer id, @RequestParam("state") int state) {
		Map<String, Object> map = new HashMap<String, Object>();
		if (state == 1) {
			state = 0;
		} else {
			state = 1;
		}
		// System.out.println(id+" @@@@@####@@@@@ "+state);
		map = sysBoothService.changeBoothState(id, state);
		return map;
	}

	@ResponseBody
	@RequestMapping("saveBooth")
	public Map<String, Object> save(SysBooth sysBooth) {
		Map<String, Object> map = new HashMap<String, Object>();
		map = sysBoothService.addBooth(sysBooth);
		return map;
	}

	@ResponseBody
	@RequestMapping("delRow")
	public Map<String, Object> delRow(@RequestParam("id") Integer id) {
		Map<String, Object> map = new HashMap<String, Object>();
		map = sysBoothService.delRowBooth(id);
		return map;
	}

}
